package com.songlanyun.modules.integralrecord.controller.api;

import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.integralrecord.entity.IntegralRecord;
import com.songlanyun.modules.integralrecord.service.IntegralRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 会员积分的收支记录
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-02-25 15:52:20
 */
@RestController
@RequestMapping("api/integral/record")
public class IntegralRecordApiController extends AbstractApiController {
    @Autowired
    private IntegralRecordService integralRecordService;

    /**
     * 我的积分记录
     */
    @GetMapping("/my-list")
    //@RequiresPermissions("integralrecord:integralrecord:list")
    public R myList(@RequestParam Map<String, Object> params) {
        setUserId(params);
        PageUtils page = integralRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("integralrecord:integralrecord:info")
    public R info(@PathVariable("id") Long id) {
        IntegralRecord integralRecord = integralRecordService.getById(id);

        return R.ok().put("data", integralRecord);
    }
}
